import { Controller, Get, Post, Body, Patch, Param } from '@nestjs/common';
import { RoleService } from '../services/role.service';
import { Role } from '../entities/role.entity';

@Controller('roles')
export class RoleController {
    constructor(private readonly roleService: RoleService) {}

    @Get()
    async findAll(): Promise<Role[]> {
        return this.roleService.findAll();
    }

    @Post()
    async create(@Body() role: Role): Promise<Role> {
        return this.roleService.create(role);
    }

    @Patch(':id')
    async updateUsername(
        @Param('id') id: number,
        @Body() updateData: { username: string }
    ): Promise<Role> {
        return this.roleService.updateUsername(id, updateData.username);
    }
} 